Imports System.Web.UI

Public Class IQuestionNodeCollection
    Implements IHierarchicalEnumerable, IList, ICollection, IEnumerable

    Private _initialsize As Integer
    Private _innerList As ArrayList

    Private ReadOnly Property List() As ArrayList
        Get
            If (Me._innerList Is Nothing) Then
                Me._innerList = New ArrayList(Me._initialsize)
            End If
            Return Me._innerList
        End Get
    End Property


    Public Sub New()
        Me._initialsize = 10
    End Sub

    Friend Shared Empty As IQuestionNodeCollection


#Region "ICollection"

    Public Overridable Sub CopyTo(ByVal array As IQuestionNode(), ByVal index As Integer)
        Me.CopyToInternal(array, index)
    End Sub

    Friend Overridable Sub CopyToInternal(ByVal array As Array, ByVal index As Integer)
        Me.List.CopyTo(array, index)
    End Sub

    Private Sub CopyTo(ByVal array As System.Array, ByVal index As Integer) Implements System.Collections.ICollection.CopyTo
        Me.CopyToInternal(array, index)
    End Sub

    Public ReadOnly Property Count() As Integer Implements System.Collections.ICollection.Count
        Get
            Return Me.List.Count
        End Get
    End Property

    Public ReadOnly Property IsSynchronized() As Boolean Implements System.Collections.ICollection.IsSynchronized
        Get
            Return Me.List.IsSynchronized
        End Get
    End Property

    Public ReadOnly Property SyncRoot() As Object Implements System.Collections.ICollection.SyncRoot
        Get
            Return Me.List.SyncRoot
        End Get
    End Property

#End Region


#Region "IEnumerable"

    Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
        Return Me.List.GetEnumerator
    End Function

#End Region


#Region "IList"

    Public Overridable Function Add(ByVal value As IQuestionNode) As Integer
        If (value Is Nothing) Then
            Throw New ArgumentNullException("value")
        End If
        Return Me.List.Add(value)
    End Function

    Private Function Add(ByVal value As Object) As Integer Implements System.Collections.IList.Add
        Return Me.Add(CType(value, IQuestionNode))
    End Function

    Public Sub Clear() Implements System.Collections.IList.Clear
        Me.List.Clear()
    End Sub

    Public Overridable Function Contains(ByVal value As IQuestionNode) As Boolean
        Return Me.List.Contains(value)
    End Function

    Private Function Contains(ByVal value As Object) As Boolean Implements System.Collections.IList.Contains
        Return Me.Contains(CType(value, IQuestionNode))
    End Function

    Public Overridable Function IndexOf(ByVal value As IQuestionNode) As Integer
        Return Me.List.IndexOf(value)
    End Function

    Private Function IndexOf(ByVal value As Object) As Integer Implements System.Collections.IList.IndexOf
        Return Me.IndexOf(CType(value, IQuestionNode))
    End Function

    Public Overridable Sub Insert(ByVal index As Integer, ByVal value As IQuestionNode)
        If (value Is Nothing) Then
            Throw New ArgumentNullException("value")
        End If
        Me.List.Insert(index, value)
    End Sub

    Private Sub Insert(ByVal index As Integer, ByVal value As Object) Implements System.Collections.IList.Insert
        Me.Insert(index, CType(value, IQuestionNode))
    End Sub

    Public ReadOnly Property IsFixedSize() As Boolean Implements System.Collections.IList.IsFixedSize
        Get
            Return False
        End Get
    End Property

    Public ReadOnly Property IsReadOnly() As Boolean Implements System.Collections.IList.IsReadOnly
        Get
            Return False
        End Get
    End Property

    Default Public Overridable Property Item(ByVal index As Integer) As IQuestionNode
        Get
            Return CType(Me.List.Item(index), IQuestionNode)
        End Get
        Set(ByVal value As IQuestionNode)
            If (value Is Nothing) Then
                Throw New ArgumentNullException("value")
            End If
            Me.List.Item(index) = value
        End Set
    End Property

    Private Property Item1(ByVal index As Integer) As Object Implements System.Collections.IList.Item
        Get
            Return Me.Item(index)
        End Get
        Set(ByVal value As Object)
            Me.Item(index) = CType(value, IQuestionNode)
        End Set
    End Property

    Public Overridable Sub Remove(ByVal value As IQuestionNode)
        If (value Is Nothing) Then
            Throw New ArgumentNullException("value")
        End If
        Me.List.Remove(value)
    End Sub

    Private Sub Remove(ByVal value As Object) Implements System.Collections.IList.Remove
        Me.Remove(CType(value, IQuestionNode))
    End Sub

    Public Sub RemoveAt(ByVal index As Integer) Implements System.Collections.IList.RemoveAt
        Me.List.RemoveAt(index)
    End Sub

#End Region


#Region "IHierarchicalEnumerable"

    Public Function GetHierarchyData(ByVal enumeratedItem As Object) As System.Web.UI.IHierarchyData Implements System.Web.UI.IHierarchicalEnumerable.GetHierarchyData
        Return TryCast(enumeratedItem, IHierarchyData)
    End Function

#End Region

End Class